package com.etc.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.etc.dao.MedicalHistoryInfoMapper;
import com.etc.dao.MedicalHistoryMapper;
import com.etc.dao.PatientMapper;
import com.etc.dao.PrescriptionMapper;
import com.etc.entity.Doctor_Patient;
import com.etc.entity.HistoryInfo;
import com.etc.entity.MedicalHistory;
import com.etc.entity.Patient;
import com.etc.entity.Prescription;
import com.etc.service.PatientService;
@Service(value="patientService")
public class PatientServiceImpl implements PatientService {
	@Resource
	private PatientMapper patientmapper;
	@Resource
	private MedicalHistoryMapper medicalHistorydMapper;
	@Resource
	private MedicalHistoryInfoMapper mhim;
	@Resource
	private PrescriptionMapper prescriptionMapper;
	
	/**
	 * 查询单个病人
	 */
	@Override
	public Patient selPatientById(String patientTel) {
		// TODO Auto-generated method stub
		return patientmapper.selectByPrimaryKey(patientTel);
	}
	
	/**
	 * 查询所有病人
	 */
	@Override
	public List<Patient> selectPatient() {
		// TODO Auto-generated method stub
		return patientmapper.selectPatient();
	}
	/**
     * 医生查询病人详情
     * @param patientTel
     * @return
     */
	@Override
	public List<MedicalHistory> selectByPatientTel(String patientTel) {
		// TODO Auto-generated method stub
		return medicalHistorydMapper.selectByPatientTel(patientTel);
	}
	/**
	 * 更新病人信息
	 */
	@Override
	public boolean updatePatient(Patient patient) {
		// TODO Auto-generated method stub
		return patientmapper.updateByPrimaryKeySelective(patient)>0;
	}

	@Override
	public List<HistoryInfo> selPatientInfoByTel(String Tel,int pageStar,int pageSize) {
		// TODO Auto-generated method stub
		return mhim.selMedicalHistoryByTel(Tel,pageStar,pageSize);
	}
	/**
	 * 医生根据手机查询病人
	 */
	@Override
	public Patient selByTel(String patientTel) {
		// TODO Auto-generated method stub
		return patientmapper.selByTel(patientTel);
	}
	/**
	 * 医生查看药方
	 */
	@Override
	public List<Prescription> getPrescription(int patientSituationId) {
		// TODO Auto-generated method stub
		return prescriptionMapper.selPrescription(patientSituationId);
	}
	/**
	 * 根据日期查询处方
	 * @param tel
	 * @param date
	 * @return
	 */
	@Override
	public List<HistoryInfo> selMedicineByDate(String tel, String date) {
		// TODO Auto-generated method stub
		return mhim.selMedicineByDate(tel, date);
	}

	@Override
	public boolean insert(Patient patient) {
		// TODO Auto-generated method stub
		return patientmapper.insert(patient)>0;
	}

	

}
